﻿using AutoMapper;
using Pay.DTO;
using Pay.IService;
using Pay.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pay.Service.AutoMapper {
   
    public class IPFilterMapper : IStartupDto {
        private IMapperConfigurationExpression _cfg;
        public IPFilterMapper(IMapperConfigurationExpression cfg) {
            _cfg = cfg;
        }
        public void Execute() {
            Create();
        }
        protected virtual void Create() {
            _cfg.CreateMap<IPFilterInfo, ip_filter_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.create_time, src => src.MapFrom(c => c.CreateTime))
                .ForMember(dest => dest.int_ip, src => src.MapFrom(c => c.IntIp))
                .ForMember(dest => dest.is_wihte_ip, src => src.MapFrom(c => c.IsWihteIp))
                .ForMember(dest => dest.ip, src => src.MapFrom(c => c.Ip));



            _cfg.CreateMap<ip_filter_dto, IPFilterInfo>()
                .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
                .ForMember(dest => dest.CreateTime, src => src.MapFrom(c => c.create_time))
                .ForMember(dest => dest.IntIp, src => src.MapFrom(c => c.int_ip))
                .ForMember(dest => dest.IsWihteIp, src => src.MapFrom(c => c.is_wihte_ip))
                .ForMember(dest => dest.Ip, src => src.MapFrom(c => c.int_ip));

        }
    }
}
